<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script src="js/jquery/jquery-1.7.2.js"></script> 
  </head>
  <script type="text/javascript">
  	function getUser(){
  		var gid = $("#id").val();
  		$.post("<%=path %>/user/findUser",{id:gid}, function(data, state){
  			alert('OK');
  			$("#userName").val(data.user.userName);
  			$("#password").val(data.user.password);
  		},
  		"json");
  	}
  </script>
  <body>
    <h2>This is index.jsp Page. </h2><br>
    <h3><a href="<%=path %>/user/findAll" name="all">查看所有</a></h3>
    <form action="<%=path %>/user/save" name="myform" method="post">
    	<table>
    		<tr>
    			<td>
    				<label title="userName">用户名： </label>
    			</td>
    			<td>
    				<input id="userName" type="text" name="user.userName" value=""/><br>
    			</td>
    		</tr>
    		<tr>
    			<td>
    				<label title="password">密码： </label>
    			</td>
    			<td>
    				<input id="password" type="text" name="user.password" value=""/><br>
    			</td>
    		</tr>
    		<tr>
    			<td colspan="2">
    				<button name="btnOk" type="submit" >submit</button>
    			</td>
    		</tr>
			<tr>
				<td>
					<input type="text" name="id" id="id" value="" />
				</td>
				<td>
    				<a href="#" name="check" onclick="getUser()" title="click me">getUser</a>
				</td>
			</tr>	    		
    	</table>
    </form>
  </body>
</html>